﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Bitirme.DAL.Entities;
using Bitirme.DAL.Enum;
using Bitirme.DAL.Data_Access;

namespace Bitirme.Controllers
{
    public class EmployeeHandler
    {
        public int InsertEmployee(string name, string surname, string email, decimal salaryPerDay, float hourPerDay)
        {

            Employee employee = new Employee();
            employee.Name = name;
            employee.SurName = surname;
            employee.Email = email;
            employee.SalaryPerDay = salaryPerDay;
            employee.HourPerDay = hourPerDay;

            return EmployeeCollection.InsertEmployee(employee);

        }
        public int InsertEmployeeToCapability(int employeeID, Dictionary<int,int>capabilityMap){
            return EmployeeToCapabilityCollection.InsertEmployeeToCapability(employeeID, capabilityMap); ;
        }

        public List<Employee> GetAllEmployees()
        {
            return EmployeeCollection.GetAllEmployees();
        }

        public List<Employee> GetAllEmployeesWithSkills()
        {
            List<Employee> employeeList;
            employeeList = EmployeeCollection.GetAllEmployees();

            foreach (Employee employee in employeeList)
            {
                /*** Her employee için yetenekleri getirilecek ***/
                employee.Skills = EmployeeToCapabilityCollection.GetCapabilitiesByEmployeeId(employee.ID);
            }

            return employeeList;
        }

        public Employee GetEmployeeByID(int employeeID) {
            Employee emp = new Employee();
            emp = EmployeeCollection.GetEmployeeByID(employeeID);
            emp.Skills = EmployeeToCapabilityCollection.GetCapabilitiesByEmployeeId(emp.ID);
            return emp;
        }

        public Boolean DeleteEmployeeByEmployeeID(int employeeID) {

            return EmployeeCollection.DeleteEmployeeByID(employeeID);
        }

        public Boolean DeleteEmployeeToCapabilityByEmployeeID(int employeeID) {

            return EmployeeToCapabilityCollection.DeleteEmployeeToCapabilityByEmployeeID(employeeID);
        }
    }
}